<?php


namespace app\data\model;

/**
 * 企业免审即享表-发布免审即享政策时生成数据
 * Class DataEnterpriseFreePolicy
 * @package app\data\model
 */
class DataEnterpriseFreePolicy extends \think\admin\Model
{
    protected $statusArr = [
        self::STATUS_WAIT    => '待兑付',
        self::STATUS_SUCCESS => '已兑付',
    ];
    const STATUS_WAIT    = 0;
    const STATUS_SUCCESS = 1;

    /**
     * 获取状态文字
     * @param $val
     * @return string
     */
    public function getStatusTxt($val): string
    {
        return $this->statusArr[$val] ?? '-';
    }

    public function enterprise()
    {
        return $this->hasOne(DataQiyeXinxiku::class, 'id', 'enterprise_id');
    }

    public function policy()
    {
        return $this->hasOne(DataMsjx::class, 'id', 'policy_id');
    }

    public function item()
    {
        return $this->hasOne(DataPolicyItem::class, 'id', 'policy_item_id');
    }

    public function setStatusSuccess()
    {
        $this->status = self::STATUS_SUCCESS;
        $this->save();
    }
}